import 'package:flutter/material.dart';

///自定义阴影效果
class ShadowText extends StatelessWidget {
  //text
  final String content;
  final TextAlign? textAlign;
  final int? maxLines;
  final TextOverflow? overflow;
  final bool? softWrap;

  //style
  final Color? color;
  final double? fontSize;
  final FontWeight? fontWeight;
  final bool? shadow;

  final VoidCallback? tabCallback;
  final EdgeInsets? padding;
  final Color shadowColor;
  const ShadowText(
    this.content, {
    super.key,
    this.textAlign,
    this.maxLines,
    this.overflow,
    this.softWrap,
    this.color,
    this.fontSize,
    this.fontWeight,
    this.tabCallback,
    this.padding,
    this.shadow = true,
    this.shadowColor = const Color(0xff999999),
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: tabCallback,
      child: Padding(
        padding: padding ?? const EdgeInsets.all(0),
        child: Text(
          content,
          textAlign: textAlign,
          maxLines: maxLines,
          overflow: overflow,
          softWrap: softWrap,
          style: TextStyle(
            fontSize: fontSize,
            color: color,
            height: 1.5,
            fontWeight: FontWeight.normal,
            shadows: (shadow == false)
                ? null
                :  [
                    Shadow(
                      color: shadowColor,
                      offset: const Offset(1, 1),
                      blurRadius: 5,
                    ),
                  ],
          ),
        ),
      ),
    );
  }
}
